Skip to content

Symfony: skip services not instantiated by the DIC#348

Merged
janedbal merged 1 commit intomasterfrom
symfony-skip-non-instantiated-services
Apr 20, 2026
Merged

Symfony: skip services not instantiated by the DIC#348
janedbal merged 1 commit intomasterfrom
symfony-skip-non-instantiated-services

Conversation

@janedbal
Copy link
Copy Markdown
Member

@janedbal janedbal commented Apr 20, 2026

Summary

  • Services tagged container.error or container.excluded, or marked abstract="true" / synthetic="true" in the dumped container XML are never constructed by the container. Skip them in SymfonyUsageProvider::fillDicClasses() so their constructors, <call> methods, <factory> methods, and tag memberships are not registered as DIC usage.
  • Verified against vendor/symfony/dependency-injection:
    • ContainerBuilder::doGet() throws RuntimeException before createService() when hasErrors() is true (container.error) or isSynthetic() is true.
    • FileLoader::addContainerExcludedTag() marks container.excluded services abstract → findDefinition/autowiring excludes them; AutowirePass.php:493 confirms.
    • Abstract definitions cannot be instantiated; by the time the XML is dumped ResolveChildDefinitionsPass has already resolved ChildDefinitions into concrete entries.
  • Not skipped: deprecated (still instantiated, just emits notice), lazy (still instantiated via proxy), public="false" (private services still instantiated when referenced).

Co-Authored-By: Claude Code

Services tagged `container.error` / `container.excluded`, or marked
`abstract="true"` / `synthetic="true"` in the dumped container XML are
never constructed by the container at runtime (verified in vendor:
ContainerBuilder::doGet throws before createService for errored and
synthetic definitions; abstract ones cannot be instantiated directly;
container.excluded implies abstract). Stop registering their
constructors, calls, factories, and tags as DIC usage so such members
can be reported as dead when nothing else uses them.

Co-Authored-By: Claude Code
@janedbal janedbal marked this pull request as ready for review April 20, 2026 13:27
@janedbal janedbal merged commit 74e7ddf into master Apr 20, 2026
32 checks passed
@janedbal janedbal deleted the symfony-skip-non-instantiated-services branch April 20, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant